<template>
	<!-- :iconLeft="true" 显示左返回 || :isBack="true" @goBack="goBack" ：自定义返回； 不写默认返回上一层 -->
	<view>
		<view class="navBar ff-flex ff-relative" :style="navStyle">
			<view class="content ff-text-center">
				<view class="iconLeft w-align-items-one" v-if="iconLeft" @click="backClick">
					<image src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/new-fire-iot/backIcon.png" mode=""></image>
				</view>
				{{ props.title }}
			</view>
			<!-- #ifdef APP-PLUS -->
			<view class="rightBtn ff-font-13">
				<view v-if="rightTypeIndex === 1">添加分组</view>
				<view v-else-if="rightTypeIndex === 2">批量移动</view>
				<view v-else-if="rightTypeIndex === 3">取消</view>
				<view v-else-if="rightTypeIndex === 4">分组管理</view>
				<view v-else-if="rightTypeIndex === 5">设备排序</view>
				<view v-else-if="rightTypeIndex === 6">分享分组</view>
			</view>
			<!-- #endif -->
		</view>
		<view :style="tabberStyle"></view>
	</view>
</template>

<script lang="ts" setup>
import { computed, getCurrentInstance } from 'vue';
const { proxy } = getCurrentInstance();
let props = defineProps(['iconLeft', 'title', 'isBack', 'rightTypeIndex']);
import { navigateBack } from '@/utils/pageJump.js';
const navStyle = computed(() => {
	const lineHeight = proxy.customBar - proxy.statusBar;
	return `padding-top:${proxy.statusBar}px;line-height:${lineHeight}px`; //height:${proxy.customBar}px;
});
const tabberStyle = computed(() => {
	return `height:${proxy.customBar}px;`;
});
// 点击返回按钮
const emit = defineEmits(['goBack']); // 不能在局部使用, defineEmits如果放在局部。不在全局。则报错
let backClick = () => {
	if (props.isBack) {
		emit('goBack');
		return;
	}
	navigateBack(); // 返回上一步
};
</script>

<style lang="scss" scoped>
.navBar {
	background: url('https://fire-system.oss-cn-beijing.aliyuncs.com/web/new-fire-iot/naberBg.png') no-repeat;
	background-size: cover;
	position: fixed;
	left: 0;
	top: 0;
	width: 100%;
	z-index: 9;
	opacity: 1;
	background-color: #dde7fa; // #3178ff;
	color: #ffffff;
	.content {
		flex: 1;
		font-size: 32rpx;
		font-weight: 500;
		display: flex;
		align-items: center;
		justify-content: center;
		.iconLeft {
			position: absolute;
			left: 0;
			padding: 10rpx 30rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			image {
				width: 30rpx;
				height: 30rpx;
			}
			:deep(.arrow-left) {
				font-weight: 300 !important;
				margin-right: 6rpx;
			}
		}
	}
	.rightBtn {
		position: absolute;
		right: 5%;
		bottom: -2%;
		z-index: 9;
	}
}
</style>